###[view/AbsenseBox.py]
from PySide6.QtWidgets import QHBoxLayout, QGroupBox

class AbsenceBox(QHBoxLayout):  # 改为继承QHBoxLayout
    """请假学生区域组件（基于水平布局）"""
    def __init__(self, type="缺勤", on_leave_click=None):
        super().__init__()
        self.type = type
        self.on_leave_click = on_leave_click
        
        # 创建容器组件
        self._container = QGroupBox(type)
        self._container.setLayout(self)  # 将自己（布局）设置给容器
        
        # 事件处理绑定
        if on_leave_click:
            self._container.mousePressEvent = self._handle_leave_click

    def _handle_leave_click(self, event):
        """处理点击事件"""
        self.on_leave_click(event)
        event.accept()

